import {useSelector, useDispatch} from "react-redux"
import {incrementAction, decrementAction, incrementPayLoadAction} from "./store/actions"

function App() {
  const num = useSelector((state) => state.num) // 获取数据
  const dispatch = useDispatch() // 修改数据的触发函数

  const decrementHandler = () => {
    dispatch(decrementAction())
  }
  const incrementHandler = () => {
    dispatch(incrementAction())
  }
  const incrementNHandler = () => {
    dispatch(incrementPayLoadAction(5))
  }
  return (
    <div className='App'>
      <button onClick={decrementHandler}>-</button>
      <p>数据：{num}</p>
      <button onClick={incrementHandler}>+</button>
      <button onClick={incrementNHandler}>+n</button>
    </div>
  )
}

export default App
